<?php

namespace backend\widgets;

use yii\base\Widget;

class ActionMenuWidget extends Widget
{
  public $default;
  public $attr = [];

  public $create  = ['title'=>'添加','href'=>'create','btn_css'=>'btn-primary','btn_id_type'=>'BX_action_null'];
  public $update  = ['title'=>'编辑','href'=>'update','btn_css'=>'btn-warning','btn_id_type'=>'BX_action_id'];
  public $views    = ['title'=>'查看','href'=>'view','btn_css'=>'btn-success','btn_id_type'=>'BX_action_id'];
  public $deleted = ['title'=>'删除','href'=>'deleted','btn_css'=>'btn-danger','btn_id_type'=>'BX_action_id_jump'];
  public $recyclebin = ['title'=>'回收站','href'=>'recyclebin','btn_css'=>'btn-default','btn_id_type'=>''];
  public $cancel = ['title'=>'恢复','href'=>'cancel','btn_css'=>'btn-primary','btn_id_type'=>'BX_action_id_jump'];
  public $index = ['title'=>'列表','href'=>'index','btn_css'=>'btn-success','btn_id_type'=>''];

  public function init()
  {
    parent::init();
  }


/*
'title' =>  '测试'
'href' =>  '/category/ceshi'
'btn_css' =>  'btn-primary'
'btn_id_type' =>  'BX_action_ids'
*/

  public function run()
  {
    //var_dump($this->attr);
    $actionId = \Yii::$app->controller->action->id;
    $actArr = [];
    if($actionId == 'index'){
      $actArr[] = $this->create;
      $actArr[] = $this->update;
      $actArr[] = $this->views;
      $actArr[] = $this->deleted;
      $actArr[] = $this->recyclebin;
      $actArr = array_merge($actArr,$this->attr);
    }else{
      $actArr[] = $this->cancel;
      $actArr[] = $this->index;
    }
    return $this->render('actionMenu',['actArr'=>$actArr]);
  }
}